package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;

import java.util.Arrays;

/**
 * 减少:
 * 用于减少流量或天数。必须绑定套餐后操作，否则无响应。
 * 接收应答一致：
 *
 */
public class SubMoneyMessage extends ProtocolMessage {

    /** 充值的数字 */
    private short charge;

    public short getCharge() {
        return charge;
    }

    public void setCharge(short charge) {
        this.charge = charge;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeShort(this.charge);
    }

    @Override
    public void onDeserialize() {
        this.charge = this.byteArray.readShort();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("SubMoneyMessage{");
        sb.append("charge=").append(charge);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
